package com.ecarx.vhaltests;

import android.util.Log;

import org.junit.Assert;

public class CallbackTimer {
    private static final int TIME_OUT = 1000;
    private boolean finish;

    public synchronized void start() {
        finish = false;
        int time = TIME_OUT;
        while (!finish && time > 0) {
            try {
                Thread.sleep(100);
                time -= 100;
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
        if (!finish) {
            Log.e("CallbackTimer", "timeout!");
            Assert.assertTrue(false);
        }
    }

    public void finish() {
        finish = true;
    }
}